package com.wzq.app.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wzq.app.R;
import com.wzq.app.base.BaseFragment;
import com.wzq.app.constant.App;
import com.wzq.app.manager.UserManager;
import com.wzq.app.ui.UserListActivity;
import com.wzq.app.utils.ToastUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @ProjectName: wzq
 * @Package: com.wzq.app.ui.fragment
 * @ClassName: FirstFragment
 * @Description: java类作用描述
 * @Version: banner1.0
 */
public class SecondFragment extends BaseFragment {
    @BindView(R.id.to_student)
    TextView toStudent;
    @BindView(R.id.to_teacher)
    TextView toTeacher;
    @BindView(R.id.to_each)
    TextView toEach;
    Unbinder unbinder;
    @BindView(R.id.query_teacher)
    TextView queryTeacher;
    @BindView(R.id.query_student)
    TextView queryStudent;

    @NonNull
    @Override
    public int getLayoutId() {
        return R.layout.second_fragment;
    }

    @Override
    public void configView() {

        if (App.TEACHER.equals(UserManager.getInstance().getUser().getType())) {
            toTeacher.setVisibility(View.GONE);
            toStudent.setVisibility(View.VISIBLE);
            toEach.setVisibility(View.VISIBLE);
            queryTeacher.setVisibility(View.GONE);
            queryStudent.setVisibility(View.GONE);
        }

        if (App.STUDENT.equals(UserManager.getInstance().getUser().getType())) {
            toTeacher.setVisibility(View.VISIBLE);
            toStudent.setVisibility(View.GONE);
            toEach.setVisibility(View.GONE);
            queryTeacher.setVisibility(View.GONE);
            queryStudent.setVisibility(View.GONE);
        }

        if (App.DUDAO.equals(UserManager.getInstance().getUser().getType())) {
            toTeacher.setVisibility(View.GONE);
            toStudent.setVisibility(View.GONE);
            toEach.setVisibility(View.GONE);
            queryTeacher.setVisibility(View.VISIBLE);
            queryStudent.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void requestData() {

    }

    @OnClick({R.id.to_student, R.id.to_teacher, R.id.to_each, R.id.query_student, R.id.query_teacher})
    public void initViewClicked(View view) {
        Intent intent = new Intent(mContext, UserListActivity.class);;
        switch (view.getId()) {
            case R.id.to_student:
                intent.putExtra("name","学生列表");
                intent.putExtra("type","2");
                ToastUtils.showToast(mContext,"评价学生");
                break;
            case R.id.to_teacher:
                intent.putExtra("name","老师列表");
                intent.putExtra("type","1");
                ToastUtils.showToast(mContext,"评价老师");
                break;
            case R.id.to_each:
                intent.putExtra("name","老师列表");
                intent.putExtra("type","1");
                ToastUtils.showToast(mContext,"老师互评");
                break;
            case R.id.query_student:
                ToastUtils.showToast(mContext,"查看学生评价");
                break;
            case R.id.query_teacher:
                ToastUtils.showToast(mContext,"查看老师评价");
                break;
            default:
                break;
        }
        startActivity(intent);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
